<?php
namespace Admin\Controller;
use \Think\Controller;

class AdminController extends Controller{
	public   function __construct(){
		parent::__construct();
		if(empty($_SESSION['admin_user'])){
		$this->redirect('Public/login');
		exit;	
		}
		//V($_SESSION);
		//权限过滤
		$mname = CONTROLLER_NAME; //获取控制器名
		$aname = ACTION_NAME; //获取方法名
		$nodelist = $_SESSION['admin_user']['nodelist']; //获取权限列表
		//让超级管理员admin拥有所有权限
		if($_SESSION['admin_user']['username'] != 'admin'){
			//验证操作权限
			if(empty($nodelist[$mname]) || !in_array($aname,$nodelist[$mname])){
				$this->error("抱歉！没有操作权限！");
				exit;
			}
		}
	}
}